<template>
  <div class="dimensions-section" v-if="dimensions && dimensions.length">
    <h3>维度分析</h3>
    <div class="dimensions-grid">
      <div v-for="dimension in dimensions" :key="dimension.dimension" class="dimension-card">
        <div class="dimension-header">
          <span class="dimension-name">{{ dimension.dimension }}</span>
          <span class="dimension-score">{{ dimension.score }}</span>
          <span class="priority-badge" :class="dimension.improvement_priority">
            {{ getPriorityText(dimension.improvement_priority) }}
          </span>
        </div>
        <div class="dimension-weight">权重: {{ dimension.weight }}%</div>

        <!-- 子分数展示 -->
        <div class="sub-scores" v-if="dimension.sub_scores">
          <div class="sub-score-item" v-for="(score, key) in dimension.sub_scores" :key="key">
            <span class="sub-score-name">{{ key }}</span>
            <span class="sub-score-value">{{ score }}</span>
          </div>
        </div>

        <!-- 优势和劣势指标 -->
        <div class="indicators">
          <div class="strengths" v-if="dimension.strength_indicators?.length">
            <div class="indicator-title">优势</div>
            <div class="indicator-tags">
              <span v-for="indicator in dimension.strength_indicators" :key="indicator" class="tag strength">
                {{ indicator }}
              </span>
            </div>
          </div>
          <div class="weaknesses" v-if="dimension.weakness_indicators?.length">
            <div class="indicator-title">待改进</div>
            <div class="indicator-tags">
              <span v-for="indicator in dimension.weakness_indicators" :key="indicator" class="tag weakness">
                {{ indicator }}
              </span>
            </div>
          </div>
        </div>

        <div class="dimension-comment">{{ dimension.detailed_comment }}</div>
      </div>
    </div>

    <!-- 详细优劣势分析 -->
    <div class="detailed-analysis-section" v-if="detailedStrengths || detailedWeaknesses">
      <div class="analysis-grid">
        <div class="strengths-section" v-if="detailedStrengths">
          <h3>详细优势</h3>
          <div class="strength-items">
            <div v-for="strength in detailedStrengths" :key="strength.category" class="analysis-item strength">
              <div class="item-header">
                <span class="category">{{ strength.category }}</span>
                <span class="impact-level">{{ strength.impact_level }}</span>
              </div>
              <div class="item-content">{{ strength.specific_strength }}</div>
              <div class="item-suggestion">{{ strength.development_suggestion }}</div>
            </div>
          </div>
        </div>

        <div class="weaknesses-section" v-if="detailedWeaknesses">
          <h3>详细劣势</h3>
          <div class="weakness-items">
            <div v-for="weakness in detailedWeaknesses" :key="weakness.category" class="analysis-item weakness">
              <div class="item-header">
                <span class="category">{{ weakness.category }}</span>
                <span class="severity-level">{{ weakness.severity_level }}</span>
              </div>
              <div class="item-content">{{ weakness.specific_weakness }}</div>
              <div class="item-method">{{ weakness.improvement_method }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DimensionalAnalysis',
  props: {
    dimensions: {
      type: Array,
      default: () => []
    },
    detailedStrengths: {
      type: Array,
      default: () => []
    },
    detailedWeaknesses: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    getPriorityText(priority) {
      const priorityMap = {
        '高': '重点',
        '中': '一般',
        '低': '良好'
      };
      return priorityMap[priority] || priority;
    }
  }
};
</script>

<style scoped>
.dimensions-section {
  margin: 40px 0;
}

.dimensions-section h3 {
  color: #333;
  margin-bottom: 25px;
  font-size: 1.4rem;
}

.dimensions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 25px;
}

.dimension-card {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 25px;
  border-left: 4px solid #3a86ff;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dimension-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.dimension-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.dimension-name {
  font-weight: 600;
  color: #333;
  font-size: 1.1rem;
}

.dimension-score {
  font-size: 1.8rem;
  font-weight: bold;
  color: #3a86ff;
}

.priority-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.priority-badge.高 {
  background: #ffebee;
  color: #c62828;
}

.priority-badge.中 {
  background: #fff3e0;
  color: #ef6c00;
}

.priority-badge.低 {
  background: #e8f5e8;
  color: #2e7d32;
}

.dimension-weight {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 15px;
}

.sub-scores {
  margin: 15px 0;
  padding: 15px;
  background: white;
  border-radius: 8px;
}

.sub-score-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sub-score-name {
  color: #666;
  font-size: 0.9rem;
}

.sub-score-value {
  font-weight: 600;
  color: #3a86ff;
}

.indicators {
  margin: 20px 0;
}

.indicator-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
}

.indicator-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 15px;
}

.tag {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.tag.strength {
  background: #e8f5e8;
  color: #2e7d32;
}

.tag.weakness {
  background: #ffebee;
  color: #c62828;
}

.dimension-comment {
  color: #555;
  line-height: 1.5;
  font-size: 0.95rem;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #e9ecef;
}

.detailed-analysis-section {
  margin-top: 40px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 30px;
}

.strengths-section,
.weaknesses-section {
  padding: 25px;
  border-radius: 12px;
}

.strengths-section {
  background: linear-gradient(135deg, #e8f5e8, #f1f8e9);
  border-left: 4px solid #4caf50;
}

.weaknesses-section {
  background: linear-gradient(135deg, #ffebee, #fce4ec);
  border-left: 4px solid #f44336;
}

.strengths-section h3 {
  color: #2e7d32;
  margin-bottom: 20px;
}

.weaknesses-section h3 {
  color: #c62828;
  margin-bottom: 20px;
}

.analysis-item {
  background: white;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.category {
  font-weight: 600;
  color: #333;
}

.impact-level,
.severity-level {
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
}

.impact-level {
  background: #e8f5e8;
  color: #2e7d32;
}

.severity-level {
  background: #ffebee;
  color: #c62828;
}

.item-content {
  color: #555;
  line-height: 1.5;
  margin-bottom: 10px;
}

.item-suggestion,
.item-method {
  color: #666;
  font-size: 0.9rem;
  line-height: 1.4;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 3px solid #3a86ff;
}
</style>